package interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ykj on 16/3/1.
 */
public class UserLoginJsonInterceptor implements Interceptor {
    public void intercept(Invocation inv) {
        if(inv.getController().getSession().getAttribute("user")!=null){
            inv.invoke();
        }else{
            Map map = new HashMap();
            map.put("needLogin",true);
            inv.getController().renderJson(map);
        }
    }
}
